#include "ScnsPcf8574.c.h"

#if defined(SCNS_PCF8574_ENABLE)&&SCNS_PCF8574_ENABLE==1

#include "ScnsIic.h"

#if !(defined(SCNS_IIC_ENABLE)&&SCNS_IIC_ENABLE==1)

#include "i2c.h"

#endif

//static const uint8 device[SCNS_PCF8574_MAX]={0X40,0X72,0X7E};
static const uint8 device[SCNS_PCF8574_MAX]={0X70};

ScnsStatus scnsBspPcf8574Write(ScnsPcf8574Enum pcfN,const uint8*data,uint8 dataLen)
{
#if defined(SCNS_IIC_ENABLE)&&SCNS_IIC_ENABLE==1
    return scnsIicWriteTick(SCNS_IIC_SOFT_1,device[pcfN],NULL,0,data,dataLen,32);
#else
    HAL_I2C_Master_Transmit(&hi2c1,device[pcfN],data,dataLen,0XFF);
    return SCNS_STATUS_OK;
#endif
}

ScnsStatus scnsBspPcf8574Read(ScnsPcf8574Enum pcfN,uint8*data,uint8 dataLen)
{
#if defined(SCNS_IIC_ENABLE)&&SCNS_IIC_ENABLE==1
    return scnsIicReadTick(SCNS_IIC_SOFT_1,device[pcfN],NULL,0,data,dataLen,32);
#else
    HAL_I2C_Master_Receive(&hi2c1,device[pcfN],data,dataLen,0XFF);
    return SCNS_STATUS_OK;
#endif
}

uint8 scnsBspPcf8574GetInt(ScnsPcf8574Enum pcfN)
{
    return (PCF_INT_GPIO_Port->IDR&PCF_INT_Pin)?1:0;
}

#endif
